package abs.dao;

import abs.domain.Sucursales;

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.skyway.spring.util.dao.AbstractJpaDao;

import org.springframework.dao.DataAccessException;

import org.springframework.stereotype.Repository;

import org.springframework.transaction.annotation.Transactional;

/**
 * DAO to manage Sucursales entities.
 * 
 */
@Repository("SucursalesDAO")
@Transactional
public class SucursalesDAOImpl extends AbstractJpaDao<Sucursales> implements
		SucursalesDAO {

	/**
	 * Set of entity classes managed by this DAO.  Typically a DAO manages a single entity.
	 *
	 */
	private final static Set<Class<?>> dataTypes = new HashSet<Class<?>>(Arrays.asList(new Class<?>[] { Sucursales.class }));

	/**
	 * EntityManager injected by Spring for persistence unit absV2
	 *
	 */
	@PersistenceContext(unitName = "absV2")
	private EntityManager entityManager;

	/**
	 * Instantiates a new SucursalesDAOImpl
	 *
	 */
	public SucursalesDAOImpl() {
		super();
	}

	/**
	 * Get the entity manager that manages persistence unit 
	 *
	 */
	public EntityManager getEntityManager() {
		return entityManager;
	}

	/**
	 * Returns the set of entity classes managed by this DAO.
	 *
	 */
	public Set<Class<?>> getTypes() {
		return dataTypes;
	}

	/**
	 * JPQL Query - findSucursalesByCo001esta
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001esta(String co001esta) throws DataAccessException {

		return findSucursalesByCo001esta(co001esta, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001esta
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001esta(String co001esta, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001esta", startResult, maxRows, co001esta);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001fead
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001fead(java.util.Calendar co001fead) throws DataAccessException {

		return findSucursalesByCo001fead(co001fead, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001fead
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001fead(java.util.Calendar co001fead, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001fead", startResult, maxRows, co001fead);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001cdgoContaining
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001cdgoContaining(String co001cdgo) throws DataAccessException {

		return findSucursalesByCo001cdgoContaining(co001cdgo, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001cdgoContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001cdgoContaining(String co001cdgo, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001cdgoContaining", startResult, maxRows, co001cdgo);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001nombContaining
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001nombContaining(String co001nomb) throws DataAccessException {

		return findSucursalesByCo001nombContaining(co001nomb, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001nombContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001nombContaining(String co001nomb, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001nombContaining", startResult, maxRows, co001nomb);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001loadContaining
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001loadContaining(String co001load) throws DataAccessException {

		return findSucursalesByCo001loadContaining(co001load, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001loadContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001loadContaining(String co001load, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001loadContaining", startResult, maxRows, co001load);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001lomo
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001lomo(String co001lomo) throws DataAccessException {

		return findSucursalesByCo001lomo(co001lomo, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001lomo
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001lomo(String co001lomo, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001lomo", startResult, maxRows, co001lomo);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001feadBefore
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001feadBefore(java.util.Calendar co001fead) throws DataAccessException {

		return findSucursalesByCo001feadBefore(co001fead, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001feadBefore
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001feadBefore(java.util.Calendar co001fead, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001feadBefore", startResult, maxRows, co001fead);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001cdgo
	 *
	 */
	@Transactional
	public Sucursales findSucursalesByCo001cdgo(String co001cdgo) throws DataAccessException {

		return findSucursalesByCo001cdgo(co001cdgo, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001cdgo
	 *
	 */

	@Transactional
	public Sucursales findSucursalesByCo001cdgo(String co001cdgo, int startResult, int maxRows) throws DataAccessException {
		try {
			Query query = createNamedQuery("findSucursalesByCo001cdgo", startResult, maxRows, co001cdgo);
			return (abs.domain.Sucursales) query.getSingleResult();
		} catch (NoResultException nre) {
			return null;
		}
	}

	/**
	 * JPQL Query - findSucursalesByCo001nomb
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001nomb(String co001nomb) throws DataAccessException {

		return findSucursalesByCo001nomb(co001nomb, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001nomb
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001nomb(String co001nomb, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001nomb", startResult, maxRows, co001nomb);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001femoBefore
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001femoBefore(java.util.Calendar co001femo) throws DataAccessException {

		return findSucursalesByCo001femoBefore(co001femo, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001femoBefore
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001femoBefore(java.util.Calendar co001femo, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001femoBefore", startResult, maxRows, co001femo);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001load
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001load(String co001load) throws DataAccessException {

		return findSucursalesByCo001load(co001load, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001load
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001load(String co001load, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001load", startResult, maxRows, co001load);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001estaContaining
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001estaContaining(String co001esta) throws DataAccessException {

		return findSucursalesByCo001estaContaining(co001esta, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001estaContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001estaContaining(String co001esta, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001estaContaining", startResult, maxRows, co001esta);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001lomoContaining
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001lomoContaining(String co001lomo) throws DataAccessException {

		return findSucursalesByCo001lomoContaining(co001lomo, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001lomoContaining
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001lomoContaining(String co001lomo, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001lomoContaining", startResult, maxRows, co001lomo);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001femo
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001femo(java.util.Calendar co001femo) throws DataAccessException {

		return findSucursalesByCo001femo(co001femo, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001femo
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001femo(java.util.Calendar co001femo, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001femo", startResult, maxRows, co001femo);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findAllSucursaless
	 *
	 */
	@Transactional
	public Set<Sucursales> findAllSucursaless() throws DataAccessException {

		return findAllSucursaless(-1, -1);
	}

	/**
	 * JPQL Query - findAllSucursaless
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findAllSucursaless(int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findAllSucursaless", startResult, maxRows);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByCo001feadAfter
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001feadAfter(java.util.Calendar co001fead) throws DataAccessException {

		return findSucursalesByCo001feadAfter(co001fead, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001feadAfter
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001feadAfter(java.util.Calendar co001fead, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001feadAfter", startResult, maxRows, co001fead);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * JPQL Query - findSucursalesByPrimaryKey
	 *
	 */
	@Transactional
	public Sucursales findSucursalesByPrimaryKey(String co001cdgo) throws DataAccessException {

		return findSucursalesByPrimaryKey(co001cdgo, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByPrimaryKey
	 *
	 */

	@Transactional
	public Sucursales findSucursalesByPrimaryKey(String co001cdgo, int startResult, int maxRows) throws DataAccessException {
		try {
			Query query = createNamedQuery("findSucursalesByPrimaryKey", startResult, maxRows, co001cdgo);
			return (abs.domain.Sucursales) query.getSingleResult();
		} catch (NoResultException nre) {
			return null;
		}
	}

	/**
	 * JPQL Query - findSucursalesByCo001femoAfter
	 *
	 */
	@Transactional
	public Set<Sucursales> findSucursalesByCo001femoAfter(java.util.Calendar co001femo) throws DataAccessException {

		return findSucursalesByCo001femoAfter(co001femo, -1, -1);
	}

	/**
	 * JPQL Query - findSucursalesByCo001femoAfter
	 *
	 */

	@SuppressWarnings("unchecked")
	@Transactional
	public Set<Sucursales> findSucursalesByCo001femoAfter(java.util.Calendar co001femo, int startResult, int maxRows) throws DataAccessException {
		Query query = createNamedQuery("findSucursalesByCo001femoAfter", startResult, maxRows, co001femo);
		return new LinkedHashSet<Sucursales>(query.getResultList());
	}

	/**
	 * Used to determine whether or not to merge the entity or persist the entity when calling Store
	 * @see store
	 * 
	 *
	 */
	public boolean canBeMerged(Sucursales entity) {
		return true;
	}
}
